<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			<!-- 动态组件 -->
			<component :is="type"></component>			
			<!-- <child-one v-if="type === 'child-one'"></child-one>
			<child-two v-if="type === 'child-two'"></child-two> -->
			<button type="button" @click="handleClick">change</button>
		</div>
		<script type="text/javascript">	
			Vue.component('child-one',{
				template:'<div v-once>child-one</div>'
			})
			Vue.component('child-two',{
				template:'<div v-once>child-two</div>'
			})
			
			var vm = new Vue({
				el:'#app',
				data:{
					type: 'child-one'
				},
				methods:{
					handleClick:function(){
						this.type = this.type === 'child-one' ? 'child-two' : 'child-one';
					}
				}
			});
		</script>
	</body>
</html>
